var setting = {
    loading: false,
    'username': '',
    form: {
        'oldPassword': '',
        'password': '',
        'rePassword': '',
    },
    rules: {
        oldPassword: [
            { required: true, message: '旧密码不能为空', trigger: 'blur' },
        ],
        password: [
            { required: true, message: '不能为空'}
        ],
        rePassword: [
            { required: true, message: '不能为空'},
        ]
    },
}
var vue = new Vue({
    el: '.changePwd',
    data: setting,
    methods:{
        updatePassword: function () {
            vue.$refs['form'].validate(function (v) {
                if(v){
                    var data = vue.form;
                    $.post("/user/updatePassword", data,function (msg) {
                        if(msg.status == 'SUCCESS'){
                            vue.$message.success(msg.message)
                            parent.location.reload()
                        }else{
                            vue.$message.error(msg.message);
                        }
                    })
                }
            });
            /*layer.open({
                content: '确认修改密码？',
                title: '提示',
                btn: ['确定', '取消'],
                yes: function () {
                    var data = {
                        'oldPassword': vue.oldPassword,
                        'password': vue.password,
                        'rePassword': vue.rePassword,
                    }
                    $.post("authority/updatePassword", data,function (msg) {
                        if(msg.status == 'SUCCESS'){
                            layer.msg(msg.message);
                            //location.parent.location.href = '/login2.html';
                            parent.location.reload()
                        }else{
                            layer.msg(msg.message);
                        }
                    })
                }
            })*/
        }
    }
})
$.post("authority/getLoginUser", function (user) {
    vue.username = user.user_name;
})